﻿using System;

namespace ExFlash.Records
{
    public class KerningRecord : ISwfSerializable
    {
        private readonly Boolean _wideCodes;

        public ushort FontKerningCode1
        {
            get;
            protected set;
        }

        public ushort FontKerningCode2
        {
            get;
            protected set;
        }

        public short FontKerningAdjustment
        {
            get;
            protected set;
        }

        public KerningRecord(Boolean hasWideCodes)
        {
            _wideCodes = hasWideCodes;
        }
        
        #region ISwfSerializable Members

        public void SwfDeserialize(BinaryBitReader reader)
        {
            if (_wideCodes)
            {
                FontKerningCode1 = reader.ReadUInt16();
                FontKerningCode2 = reader.ReadUInt16();
            }
            else
            {
                FontKerningCode1 = reader.ReadByte();
                FontKerningCode2 = reader.ReadByte();
            }

            FontKerningAdjustment = reader.ReadInt16();
        }

        public void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
